import { CommonModel } from '.'
import { authorizeRequest, unauthorizeRequest } from '../util/http'

export interface PostTokenParams {
    username: string;
    password: string;
}
type TokenResponse = {
    token:string;
}

export interface User extends CommonModel {
    username: string;
    password: string;
}
export const apiPostToken = async (params:PostTokenParams)=>{
    return (await unauthorizeRequest.post<TokenResponse>('token',params)).data
}

export const apiGetToken = async ()=>{
    return (await authorizeRequest.get<User>('token')).data
}